﻿namespace Client
{
    public class RepositoryManager
    {
        private string login;
        private string password;

        private RepositoryManager(string _login, string _password)
        {
            login    = _login;
            password = _password;
        }
        
        private static RepositoryManager repositoryManager = null;
        public  static RepositoryManager GetRepositoryManager(string login, string password)
        {
            if (repositoryManager == null ||
                    repositoryManager.login != login ||
                    repositoryManager.password != password)
            {
                repositoryManager = new RepositoryManager(login, password);
            }
            
            return repositoryManager;
        }

        private IPositionRepository positionRepository = null;
        public  IPositionRepository PositionRepository
        {
            get
            {
                if (positionRepository == null)
                {
                    positionRepository = new PositionRepository(login, password);
                }
                return positionRepository;
            }
        }

        private IBankAccountRepository bankAccountRepository = null;
        public  IBankAccountRepository BankAccountRepository
        {
            get
            {
                if (bankAccountRepository == null)
                {
                    bankAccountRepository = new BankAccountRepository(login, password);
                }
                return bankAccountRepository;
            }
        }

        private IPaymentRepository paymentRepository = null;
        public  IPaymentRepository PaymentRepository
        {
            get
            {
                if (paymentRepository == null)
                {
                    paymentRepository = new PaymentRepository(login, password);
                }
                return paymentRepository;
            }
        }

        private ITimeTableRepository timeTableRepository = null;
        public  ITimeTableRepository TimeTableRepository
        {
            get
            {
                if (timeTableRepository == null)
                {
                    timeTableRepository = new TimeTableRepository(login, password);
                }
                return timeTableRepository;
            }
        }

        private ITaskRepository taskRepository = null;
        public  ITaskRepository TaskRepository
        {
            get
            {
                if (taskRepository == null)
                {
                    taskRepository = new TaskRepository(login, password);
                }
                return taskRepository;
            }
        }

        private IEmployeeRepository employeeRepository = null;
        public  IEmployeeRepository EmployeeRepository
        {
            get
            {
                if (employeeRepository == null)
                {
                    employeeRepository = new EmployeeRepository(login, password);
                }
                return employeeRepository;
            }
        }
    }
}
